package com.kania.todostack;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SubjectDBHelper extends SQLiteOpenHelper{
	public static final String SUBJECT_DB_NAME = "subject.db";
	public static final String SUBJECT_TABLE_NAME = "subject";
	
	public SubjectDBHelper(Context context){
		super (context, SUBJECT_DB_NAME, null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL("CREATE TABLE IF NOT EXISTS "
				+ SUBJECT_TABLE_NAME
				+ " (_id INTEGER PRIMARY KEY AUTOINCREMENT, sequence INTEGER, name TEXT, color INTEGER);");
		
		//debug
//		ContentValues cv = new ContentValues();
//		cv.put("sequence", 0);
//		cv.put("name", "firstSub");
//		cv.put("color", 0);
//		db.insert(SUBJECT_TABLE_NAME, null, cv);
//		cv.put("sequence", 1);
//		cv.put("name", "secondSub");
//		cv.put("color", 1);
//		db.insert(SUBJECT_TABLE_NAME, null, cv);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS " + SUBJECT_TABLE_NAME);
		onCreate(db);
	}
}